package com.java.controller;

import com.java.model.Advertiser;
import com.java.model.Media;
import com.java.model.Result;
import com.java.service.AdvertiserService;
import com.java.service.MediaService;
import com.java.service.TagService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Controller
public class BackIndexController {

    @Autowired
    AdvertiserService advertiserService;

    @Autowired
    MediaService mediaService;

    @Autowired
    TagService tagService;

    @RequestMapping("/BackWelcome")
    public String BackWelcome(Model model, HttpServletRequest request){
        List<Advertiser> advertisersCount = advertiserService.advertisersCount();
        model.addAttribute("advertisersCount",advertisersCount.size());
        List<Media> mediaCount = mediaService.mediaCount();
        model.addAttribute("mediaCount",mediaCount.size());
        List<Media> mediaList = mediaService.mediaCountTow();
        model.addAttribute("mediaList",mediaList.size());
        return "/admin/BackWelcome";
    }

    @RequestMapping("/tagCount")
    @ResponseBody
    public Result tagCount(){
        return tagService.tagCount();
    }

}